package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class Travel extends BaseDomain {
    public final static int STATE_REJECT = -1;//拒绝
    public final static int STATE_NORMAL = 0;//保存
    public final static int STATE_WAIT = 1;//代发布
    public final static int STATE_RELEASE = 2;//已发布

    private String title;//标题

    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date travelTime;//旅游时间

    private String perExpends;//人均消费

    private Integer days;//旅游天数

    private Integer person;//和谁旅游

    private User author;//作者

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;//创建时间

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date releaseTime;//发布时间

    private Boolean isPublic = false;//是否公开

    private Region place;//旅游地区

    private String coverUrl;//封面

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date lastUpdateTime;//最后更新时间

    private Integer state=STATE_NORMAL;//状态

    private TravelContent travelContent;//内容

    public String getStateName() {
        String temp = "";
        switch (state) {
            case STATE_REJECT: temp = "拒绝";break;
            case STATE_NORMAL: temp = "保存";break;
            case STATE_WAIT: temp = "待发布";break;
            case STATE_RELEASE: temp = "已发布";break;

        }
        return temp;
    }
    public String getPersonName() {
        String temp = "";
        switch (state) {
            case 1: temp = "一个人的旅行";break;
            case 2: temp = "和父母";break;
            case 3: temp = "和朋友";break;
            case 4: temp = "和同事";break;
            case 5: temp = "和爱人";break;
            case 6: temp = "和其他";break;

        }
        return temp;
    }

    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("coverUrl",coverUrl);
        return JSONUtil.toJSONString(map);
    }
}
